﻿using System;
using System.Collections.Generic;
using tour.szhome.common;
using TOUR.SZHOME.DAL;
using TOUR.SZHOME.Entity;
namespace TOUR.SZHOME.BLL
{
    /// <summary>
    /// 数据表Landscape的业务逻辑类
    /// </summary>
    public class LandscapeBLL
    {
        /// <summary>
        /// 获取景区列表 -- 分页
        /// </summary>
        /// <param name="pid"></param>
        /// <param name="pageSet"></param>
        /// <returns></returns>
        public List<LandscapeEntity> GetLandscapeList(PageSet pageSet)
        {
            string where = " 1 = 1 ";
            pageSet.RecordCount = LandscapeDAL.SearchCount(where);
            pageSet.PageCount = (int)Math.Ceiling(pageSet.RecordCount / (pageSet.PageSize * 1.0));
            return LandscapeDAL.Search(where, "JQID", (pageSet.PageIndex - 1) * pageSet.PageSize, pageSet.PageSize);
        }

        /// <summary>
        /// 获取所有列表，前台用
        /// </summary>
        /// <returns></returns>
        public List<LandscapeEntity> GetAllLandscape()
        {
            return LandscapeDAL.Search("1=1", "JQID", 20);
        }

        /// <summary>
        /// 根据ID获取对象实体
        /// </summary>
        /// <param name="lid"></param>
        /// <returns></returns>
        public LandscapeEntity GetLandscapeByID(int lid) 
        {
            return LandscapeDAL.GetByJQID(lid);
        }

        /// <summary>
        /// 根据ID删除对象
        /// </summary>
        /// <param name="nid"></param>
        /// <returns></returns>
        public bool DelByID(int nid)
        {
            return LandscapeDAL.Delete(nid);
        }

        /// <summary>
        /// 编辑项目的逻辑方法
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool EditLandscape(LandscapeEntity model)
        {
            if (model.JQID > 0)
            {
                return LandscapeDAL.Update(model);
            }
            else
            {
                return LandscapeDAL.Insert(model);
            }
        }
    }
}
